Skip to content

Refactor MCP shims to avoid litellm import cycles#323

Closed
chrisnestrud wants to merge 2 commits intocecli-dev:mainfrom
chrisnestrud:feature/mcp-support
Closed

Refactor MCP shims to avoid litellm import cycles#323
chrisnestrud wants to merge 2 commits intocecli-dev:mainfrom
chrisnestrud:feature/mcp-support

Conversation

@chrisnestrud
Copy link
Copy Markdown

Lazy-load litellm.experimental_mcp_client and move LocalServer helpers under aider.mcp_support so coders no longer import the heavy MCP stack at module import time. Without this change the branch repeatedly crashed pytest with circular ImportError whenever litellm shipped without the experimental MCP extras, blocking any tests that touch aider.coders.

Lazy-load litellm.experimental_mcp_client and move LocalServer helpers under aider.mcp_support so coders no longer import the heavy MCP stack at module import time. Without this change the branch repeatedly crashed pytest with circular ImportError whenever litellm shipped without the experimental MCP extras, blocking any tests that touch aider.coders.
@chrisnestrud chrisnestrud marked this pull request as draft December 28, 2025 03:08
Running the documented pre-commit hooks failed with E402/isort warnings because the lazy MCP proxy lived above the project imports. Move the proxy definitions below the import blocks in agent_coder and base_coder so auto-formatting passes.
@chrisnestrud chrisnestrud marked this pull request as ready for review December 28, 2025 03:19
@dwash96
Copy link
Copy Markdown
Collaborator

dwash96 commented Dec 28, 2025

Why change the folder name to mcp_support? I feel like if the folder name remains the same and the duplicate _ExperimentalMCPClientProxy() classes are just defined and imported inside of the mcp folder somewhere, this is fine. We have a PR about supporting oauth for MCP servers coming from Gopar in the discord, so I would prefer the file system structure stay the same to prevent conflicts with that.

I'll hold 0.91.2 since we seem to be on at the same time for this

@chrisnestrud
Copy link
Copy Markdown
Author

chrisnestrud commented Dec 28, 2025 via email

@dwash96
Copy link
Copy Markdown
Collaborator

dwash96 commented Dec 28, 2025

What modules were conflicting?

@chrisnestrud
Copy link
Copy Markdown
Author

I'm not able to reproduce this now.

@chrisnestrud chrisnestrud deleted the feature/mcp-support branch January 5, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants